#include "stdafx.h"
#include "Vector3f.h"

Vector3f::Vector3f(float x,float y,float z)
{
	this->x = x;
	this->y = y;
	this->z = z;
}

Vector3f::Vector3f()
{

}

float Vector3f::getX()
{
	return x;
}
	
float Vector3f::getY()
{
	return y;
}

float Vector3f::getZ()
{
	return z;
}

// Setters:
void Vector3f::setX(float x)
{
	this->x = x;
}
void Vector3f::setY(float y)
{
	this->y = y;
}
void Vector3f::setZ(float z)
{
	this->z = z;
}

void Vector3f::add(Vector3f *v)
{
	this->x += v->x;
	this->y += v->y;
	this->z += v->z;
}

void Vector3f::sub(Vector3f *v)
{
	this->x -= v->x;
	this->y -= v->y;
	this->z -= v->z;
}

Vector3f *Vector3f::crossProductAndAssign(Vector3f *v1, Vector3f *v2)
{
	float tempX = v1->y * v2->z - v1->z * v2->y;
	float tempY = v1->z * v2->x - v1->x * v2->z;
	float tempZ = v1->x * v2->y - v1->y * v2->x;

	// Retorno:
	return new Vector3f(tempX, tempY, tempZ);
}

float Vector3f::norm()
{
	return sqrt(this->x * this->x + this->y * this->y + this->z + this->z);
}

void Vector3f::normalize()
{
	float norm = this->norm();

	x /= norm;
	y /= norm;
	z /= norm;
}

void Vector3f::scale(float scalar) 
{
	x *= scalar;
	y *= scalar;
	z *= scalar;
}